//
//  XFXFashionView.m
//  XFXnews
//
//  Created by dllo on 16/2/27.
//  Copyright © 2016年 lanou. All rights reserved.
//

#import "XFXFashionView.h"
#import "XFX_WapModel.h"
@interface XFXFashionView ()

@property (nonatomic, retain) UILabel *titleOne;
@property (nonatomic, retain) UILabel *title;
@property (nonatomic, retain) UIScrollView *scrollView;
@property (nonatomic, retain) UIButton *button ;
@property (nonatomic, retain) UIButton *button1;

@end

@implementation XFXFashionView

- (instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
    }return self;
}

- (void)createSubViews{
    
    self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, XFXWIDTH, XFXHEIGHT * 0.25)];
    self.scrollView.pagingEnabled = YES;
    self.scrollView.bounces = NO;
    [self addSubview:self.scrollView];
    
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, self.scrollView.frame.origin.y + 2 * XFXSHEI, XFXWIDTH, 5 * XFXSHEI)];
    imageView.image = [UIImage imageNamed:@"horizontal_separator@2x.png"];
    [self addSubview:imageView];
    
    UIImageView *imageView1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, XFXHEIGHT * 0.4, XFXWIDTH, 5 * XFXSHEI)];
    imageView1.image = [UIImage imageNamed:@"horizontal_separator@2x.png"];
    [self addSubview:imageView1];
    
    UIImageView *imageView2 = [[UIImageView alloc] initWithFrame:CGRectMake(XFXHEIGHT / 2, 0, 1 * XFXSWID, 79 * XFXSHEI)];
    imageView2.image = [UIImage imageNamed:@"mashup_shadow_left@2x.png"];
    [self addSubview:imageView2];
    
    self.button = [[UIButton alloc] initWithFrame:CGRectMake(0, self.scrollView.frame.origin.y + self.scrollView.frame.size.height + 14 * XFXSHEI, XFXWIDTH / 2, XFXHEIGHT * 0.015)];
    [self addSubview:self.button];
    
    self.button1 = [[UIButton alloc] initWithFrame:CGRectMake(XFXWIDTH / 2 + 1 * XFXSWID, self.button.frame.origin.y, XFXWIDTH / 2, self.button.frame.size.height)];
    [self addSubview:self.button1];
    
}

- (void)setModel:(XFXNewsHeadLineModel *)model{
    _model = model;
    if (model.imgsrc!= 0) {
        UIImageView *imageview = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, XFXWIDTH, XFXHEIGHT * 0.25)];
        [_scrollView addSubview:imageview];
        NSURL *url = [NSURL URLWithString:model.imgsrc];
        [imageview sd_setImageWithURL:url placeholderImage:nil];
        self.title = [[UILabel alloc] initWithFrame:CGRectMake(XFXWIDTH * 0.01, XFXHEIGHT * 0.22, XFXWIDTH, 10 * XFXSHEI)];
        [imageview addSubview:self.title];
        self.title.text = model.title;
        self.title.font = [UIFont systemFontOfSize:13.0];
    }
}

-(void)setArray:(NSMutableArray *)array{
    
    _array = array;
    XFX_WapModel *modelOne = [array firstObject];
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(XFXHEIGHT * 0.13 / 3, XFXWIDTH * 0.01, 50 * XFXSWID, 50 * XFXSHEI)];
    [self.button addSubview:imageView];
    NSURL *url = [NSURL URLWithString:modelOne.imgsrc];
    [imageView sd_setImageWithURL:url placeholderImage:nil];
    self.titleOne = [[UILabel alloc]initWithFrame:CGRectMake(XFXHEIGHT * 0.13, imageView.frame.origin.y * 4, XFXWIDTH, 10 * XFXSHEI)];
    [self.button addSubview:self.titleOne];
    self.titleOne.text = modelOne.title;
    
    UILabel *lab = [[UILabel alloc] initWithFrame:CGRectMake(XFXWIDTH * 0.13, XFXHEIGHT * 0.06, XFXWIDTH, 10 * XFXSHEI)];
    lab.font = [UIFont systemFontOfSize:13.0];
    [self.button addSubview:lab];
    lab.text = modelOne.subtitle;
    
    XFX_WapModel *modelTwo = [array lastObject];
    UIImageView *imageView1 = [[UIImageView alloc] initWithFrame:CGRectMake(XFXWIDTH * 0.13 / 3, XFXHEIGHT * 0.01, 50 * XFXSWID, 50 * XFXSHEI)];
    [self.button1 addSubview:imageView1];
    NSURL *url1 = [NSURL URLWithString:modelTwo.imgsrc];
    [imageView1 sd_setImageWithURL:url1 placeholderImage:nil];
    
    UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(XFXWIDTH * 0.13, imageView.frame.origin.y * 4, XFXWIDTH, 10 * XFXSHEI)];
    [self.button1 addSubview:title];
    title.text = modelTwo.title;
    
    UILabel *subtitle = [[UILabel alloc] initWithFrame:CGRectMake(XFXWIDTH * 0.13, XFXHEIGHT * 0.06, XFXWIDTH, 10 * XFXSHEI)];
    subtitle.font = [UIFont systemFontOfSize:13.0];
    [self.button1 addSubview:subtitle];
    subtitle.text = modelTwo.subtitle;
}



@end
